home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / c / flgzero.exe / FLGZERO.LST < prev    next >
File List  |  1991-09-16  |  5KB  |  113 lines

  1. Microsoft (R) Macro Assembler Version 5.10                  9/16/91 19:16:35
  2. ZERO FLAGS    ; Set display tab to 8 characters                Page     1-1
  3.  
  4.  
  5.        1                        PAGE    ,132        ; 80 for narrow printers
  6.        2                        TITLE    ZERO FLAGS    ; Set display tab to 8 characters
  7.        3                        COMMENT    *
  8.        4                    
  9.        5                Given the base address of a flag word and the number of bits it contains,
  10.        6                this function will set all the bits in the flag word to zero (Note that it works
  11.        7                in byte increments)  The program zeros nothing if no bits are defined, allowing
  12.        8                it to be used with a variable.  It is not designed to work with negative bit counts.
  13.        9                
  14.       10                Programmed By:    A. L. Bender, M. D.
  15.       11                        Bender Consulting
  16.       12                        PO Box 8685
  17.       13                        Woodcliff Lake, NJ 07675
  18.       14                
  19.       15                Not copyright, freely in public domain.
  20.       16                Not responsible for your use or misuse of this program.
  21.       17                
  22.       18                This program was tested with Microsoft c 5.1.  It demonstrates how the bits
  23.       19                are stored in a word.  The enclosed driver program shows how to call it and
  24.       20                how to test it.  Assumes direction flag is set to FORWARD.  (An ok MSC 5.1
  25.       21                Assumption)
  26.       22                
  27.       23                The primary purpose of this program is instructional, you can hopefully learn
  28.       24                something about MASM 5.1 Programming from this, especially how to use the
  29.       25                higher level language interface.  See Microsoft MASM 5.1 Update.
  30.       26                
  31.       27                Note: This will not execute on an 8086/88 but requires at least an 80186 or V20 
  32.       28                You can remove the .186 statement to get it going on the 8086/88 if you need to
  33.       29                
  34.       30                The masm call line needs /Dmemmodel={SMALL|MEDIUM|COMPACT|LARGE} as the case
  35.       31                may be to write the proper code.
  36.       32                Example:
  37.       33                masm /Dmemmodel=SMALL /Mx flgzero,,,;  Makes a small model flgzero
  38.       34                
  39.       35                
  40.       36                *
  41.       37                        .186                    ; Set processor required
  42.       38                        IFDEF        memmodel        ; Did user define it?
  43.       39                %        .MODEL        memmodel,c        ; Use user definition
  44.       40                        ENDIF
  45.       41                        .CODE                    ;Large Model C Program
  46.       42 0000                flgzero        PROC        flagword:PTR BYTE, nrbits:WORD    ; Prologue
  47.       43 0004  8B 46 0A                    MOV        AX,nrbits        ; Get Bit count 
  48.       44 0007  85 C0                    TEST        AX,AX            ; If bits are defined (Non Degenerat
  49.                     ive Case)
  50.       45 0009  74 0F                    JZ        @F            ; don't get out
  51.       46 000B  48                    DEC        AX            ; Make count 0...7
  52.       47                        IF        @Cpu NE 0
  53.       48 000C  C1 F8 03                    SAR        AX,3            ; Divide by 8 The easy way
  54.       49                        ENDIF
  55.       50 000F  33 C9                    XOR        CX,CX            ; Prep CX for later
  56.       51 0011  40                    INC        AX            ; Insure fraction of byte is ok
  57.       52 0012  91                    XCHG        CX,AX            ; Copy Quotient of 8 to CX And Zero 
  58.                     To AX
  59. Microsoft (R) Macro Assembler Version 5.10                  9/16/91 19:16:35
  60. ZERO FLAGS    ; Set display tab to 8 characters                Page     1-2
  61.  
  62.  
  63.       53 0013  57                    PUSH        DI            ; Preserve DI from certain ruin
  64.       54                        IF        @Datasize EQ 1        ; 
  65.       55 0014  C4 7E 06                    LES        DI,flagword        ; Get the base address for large dat
  66.                     a
  67.       56                        ENDIF
  68.       57 0017  F3/ AA                    REP STOSB                ; Zero the bytes (See assumption)
  69.       58 0019  5F                    POP        DI            ; Return DI to prior state
  70.       59 001B  CB            @@:        RET                    ; Return to user program
  71.       60 001C                flgzero        ENDP                    ; Epilogue
  72.       61                        END                    ; Epitaph
  73. Microsoft (R) Macro Assembler Version 5.10                  9/16/91 19:16:35
  74. ZERO FLAGS    ; Set display tab to 8 characters                Symbols-1
  75.  
  76.  
  77. Segments and Groups:
  78.  
  79.                 N a m e             Length     Align    Combine Class
  80.  
  81. DGROUP . . . . . . . . . . . . .      GROUP
  82.   _DATA  . . . . . . . . . . . .      0000    WORD    PUBLIC    'DATA'
  83. FLGZERO_TEXT . . . . . . . . . .      001C    WORD    PUBLIC    'CODE'
  84.  
  85. Symbols:            
  86.  
  87.                 N a m e             Type     Value     Attr
  88.  
  89. FLAGWORD . . . . . . . . . . . .      TEXT  DWORD PTR [BP]+6        
  90. flgzero  . . . . . . . . . . . .      F PROC    0000    FLGZERO_TEXT    Global    Length = 001C
  91.  
  92. MEMMODEL . . . . . . . . . . . .      TEXT  LARGE        
  93.  
  94. NRBITS . . . . . . . . . . . . .      TEXT  WORD PTR [BP]+10        
  95.  
  96. @0 . . . . . . . . . . . . . . .      L NEAR    001A    FLGZERO_TEXT
  97. @CODE  . . . . . . . . . . . . .      TEXT  flgzero_TEXT        
  98. @CODESIZE  . . . . . . . . . . .      TEXT  1        
  99. @CPU . . . . . . . . . . . . . .      TEXT  259        
  100. @DATASIZE  . . . . . . . . . . .      TEXT  1        
  101. @FILENAME  . . . . . . . . . . .      TEXT  flgzero        
  102. @VERSION . . . . . . . . . . . .      TEXT  510        
  103.  
  104.  
  105.      68 Source  Lines
  106.      68 Total   Lines
  107.      23 Symbols
  108.  
  109.   47034 + 391843 Bytes symbol space free
  110.  
  111.       0 Warning Errors
  112.       0 Severe  Errors
  113.